



/**
* @file common.h
* @brief 通用头文件
* @author zshare
* @version v1.0
* @date 2018-05-09
* @history  
*/


#ifndef __COMMON__H__
#define __COMMON__H__



#define _log_
#ifdef _log_
	#define kernel_print(format, arg...) printk(format,## arg)
#else
	#define kernel_print(format, arg...) do{}while(0)
#endif
#define VERSION "V1.0"
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#define nil NULL
#define FALSE 1
#define TRUE 0
#define pcalloc(x,size,type) do{ if((x = (type *)kcalloc(1,size,GFP_KERNEL)) == nil){ return FALSE; } }while(0)
#define pfree(ptr) do{ if(ptr != nil) { kfree(ptr); } ptr = nil; }while(0)

#define ERR_BASE		(0x10000000)
#define ERR_OK			(0x00)
#define ERR_INARGERR	(ERR_BASE + 0x01)

//遍历
#define for_head_travel(count,head,tail)	\
		for(count = head;count < tail;count++)
#define for_head_tail_travel(count,head,tail)	\
		for(count = head;count <= tail;count++)
#define for_zero_travel(count,len)	\
		for(count = 0;count < len;count++)

//指针判断
#define assert_ptr(ptr)	\
do{ \
	if(ptr == nil)	return ERR_INARGERR;	\
}while(0)

//长度判断
#define assert_len_too_long(len,limit)	\
do{ \
	if(len > limit) return ERR_INARGERR;	\
}while(0)

#define assert_len_too_short(len,limit)	\
do{ \
	if(len < limit) return ERR_INARGERR;	\
}while(0)

#define assert_len_equal(len,limit)	\
do{ \
	if(len != limit)	return ERR_INARGERR;	\
}while(0)

#define assert_ecc_private_allow(plist,index)	\
do{ \
}while(0)





#endif








